package com.example.dryyzx.entity;

import com.alibaba.fastjson.JSONObject;

import java.io.Console;

/**
 * 用于封装请求结果的类
 */
public class JsonResult {
    private boolean rs;//true请求成功可取data数据  false请求失败 取errmsg
    private Object data;//返回的数据
    private String errMsg;

    public JsonResult() {
    }

    public JsonResult(boolean rs, Object data) {
        this.rs = rs;
        this.data = data;
    }

    public JsonResult(boolean rs, String errMsg) {
        this.rs = rs;
        this.errMsg = errMsg;
    }

    public JsonResult(Object data) {
        this.rs=true;
        this.data = data;
    }

    public JsonResult(String errMsg) {
        this.rs=false;
        this.errMsg = errMsg;
    }

    public boolean isRs() {
        return rs;
    }

    public void setRs(boolean rs) {
        this.rs = rs;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getErrMsg() {
        return errMsg;
    }

    public void setErrMsg(String errMsg) {
        this.errMsg = errMsg;
    }

    @Override
    public String toString() {
        return JSONObject.toJSONString(this);
    }
}
